﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Blogs01
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }

        public Form3(int Id, string Title, string Author, string CreateTime)
        {
            this.id = Id;
            textBox2.Text = Title;
            textBox1.Text = Author;
            textBox3.Text = CreateTime;
        }
        private int id;
        private void button2_Click(object sender, EventArgs e)
        {
            var ids = textBox4.Text;
            var Titles = textBox1.Text;
            var Authors = textBox2.Text;
            var Times = textBox3.Text;
            var qq = !string.IsNullOrEmpty(Authors);           
            
                if (qq)
                {
                    var sql = string.Format("insert into Articles(Id,Title,Author,CreatedTime)values({0},'{1}','{2}','{3}')", ids, Titles, Authors, Times);

                    var dt = DbHelper.Addddd(sql);
                    if (dt == 1)
                    {
                        DialogResult dr = MessageBox.Show("添加成功", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.DialogResult = DialogResult.Yes;
                        this.Close();
                    }
                    else
                    {
                        DialogResult dr = MessageBox.Show("添加失败", "添加", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
        

        private void button3_Click(object sender, EventArgs e)
        {      
            this.Close();
        }

        private void textBox4_TextChanged(object sender, EventArgs e)
        {

        }

        private void Form3_Load(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void label4_Click(object sender, EventArgs e)
        {

        }
    }
}
